package com.xjrsoft.module.customerTwo.EMP.check_in.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaMode;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.common.page.ConventPage;
import java.util.List;
import com.xjrsoft.common.result.Response;
import com.xjrsoft.core.tool.utils.BeanUtil;
import com.xjrsoft.module.customerTwo.EMP.check_in.dto.Table44924858485687615000Dto;
import com.xjrsoft.module.customerTwo.EMP.check_in.dto.SaveTable44924858485687615000FormDataDto;
import com.xjrsoft.module.customerTwo.EMP.check_in.vo.Table44924858485687615000Vo;
import com.xjrsoft.module.customerTwo.EMP.check_in.vo.Table44924858485687615000ListVo;
import com.xjrsoft.module.customerTwo.EMP.check_in.dto.Table44924858485687615000ListDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;

import org.springframework.web.bind.annotation.*;
import com.xjrsoft.module.customerTwo.EMP.check_in.entity.Table44924858485687615000;
import com.xjrsoft.module.customerTwo.EMP.check_in.vo.Table44924858485687615000Vo;
import com.xjrsoft.module.customerTwo.EMP.check_in.service.ITable44924858485687615000Service;

/**
 *  控制器
 *
 * @author system
 * @since 2024-02-28
 */
@RestController
@AllArgsConstructor
@RequestMapping("/check_in")
@Api(value = "入住登记", tags = "入住登记接口")
public class Table44924858485687615000Controller {


	private final ITable44924858485687615000Service table44924858485687615000Service;


	/**
	 * 详情 
	 */
	@GetMapping("/{id}")
	@ApiOperation(value = "详情", notes = "传入table44924858485687615000")
	@SaCheckPermission(value = {"check_in:view", "check_in:modify"}, mode = SaMode.OR)
	public Response<Table44924858485687615000Vo> getFormData(@PathVariable String id) {
		// 主表数据
		Table44924858485687615000 table44924858485687615000 = table44924858485687615000Service.getById(id);
		Table44924858485687615000Vo table44924858485687615000Vo = BeanUtil.copy(table44924858485687615000, Table44924858485687615000Vo.class);
		return Response.ok(table44924858485687615000Vo);
	}

	/**
	 * 自定义分页 
	 */
	@GetMapping
	@ApiOperation(value = "分页", notes = "传入table44924858485687615000")
		public Response<PageOutput<Table44924858485687615000ListVo>> getPageList(Table44924858485687615000ListDto listDto) {
		IPage<Table44924858485687615000> page = table44924858485687615000Service.getPageList(listDto);
		List<Table44924858485687615000ListVo> records = BeanUtil.copyList(page.getRecords(), Table44924858485687615000ListVo.class);
		return Response.ok(ConventPage.getPageOutput(page.getTotal(), records));
	}

	/**
	 * 新增 
	 */
	@PostMapping
	@ApiOperation(value = "新增", notes = "传入table44924858485687615000")
	@SaCheckPermission("check_in:add")
	public Response save(@RequestBody SaveTable44924858485687615000FormDataDto formDto) {
		Table44924858485687615000Dto table44924858485687615000Dto = formDto.getTable44924858485687615000Dto();
		Table44924858485687615000 table44924858485687615000 = BeanUtil.copy(table44924858485687615000Dto, Table44924858485687615000.class);
		boolean isSuccess = table44924858485687615000Service.addTable44924858485687615000(table44924858485687615000);
		return Response.status(isSuccess);
	}

	/**
	 * 修改 
	 */
	@PutMapping("/{id}")
	@ApiOperation(value = "修改", notes = "传入table44924858485687615000")
	@SaCheckPermission("check_in:modify")
	public Response update(@PathVariable String id, @RequestBody SaveTable44924858485687615000FormDataDto formDto) {
		Table44924858485687615000Dto table44924858485687615000Dto = formDto.getTable44924858485687615000Dto();
		Table44924858485687615000 table44924858485687615000 = BeanUtil.copy(table44924858485687615000Dto, Table44924858485687615000.class);
		return Response.status(table44924858485687615000Service.updateTable44924858485687615000(id, table44924858485687615000));
	}



	/**
	 * 删除 
	 */
	@DeleteMapping("/{ids}")
	@ApiOperation(value = "删除", notes = "传入ids")
	@SaCheckPermission(value = {"check_in:batchDelete", "check_in:delete"}, mode = SaMode.OR)
	public Response remove(@ApiParam(value = "主键集合", required = true) @PathVariable String ids) {
		return Response.status(table44924858485687615000Service.delete(ids));
	}


}
